﻿using System;
using Hprose.RPC;

namespace HproseRpcTester.RpcClient
{
    public interface IRunRPC : IRpcClientBase
    {
    }

    public class RunRPC : RpcClientBase, IRunRPC
    {
        public RunRPC()
        {
            try
            {
                //var port = JsonConvert.DeserializeObject<JToken>(File.ReadAllText($"{ApplicationPath.StartupPath}\\Config\\DesktopConfig.json")).Value<int>("RPCPort");
                var port = AppConsts.RPCPort;
                if (RPC != null) RPC.Dispose();
                RPC = null;
                RPC = new Client($"http://127.0.0.1:{port}/");
                RPC.Timeout = TimeSpan.FromSeconds(600);

                log.Debug("RPC 客户端创建成功");
            }
            catch { log.Error("初始化RunRPC失败"); }
        }
    }
}
